package {
	
	import org.cove.ape.*;
	
	public class Surfaces_Tech extends Group {
		
		private var myBlocks:Composite; // composite that contains all the walls so that we can rotate them all at once 
		
		public function Surfaces_Tech(colB:uint, colC:uint, colD:uint, colE:uint) {
			myBlocks = new Composite(); // initialize myBlocks
			
			// these groups of 3 lines each add one side of the room to the composite
			var floor:RectangleParticle = new RectangleParticle(350,400,400,20,0,true);
			floor.setStyle(0, colB, 1, colB);
			myBlocks.addParticle(floor);
			
			var ceil:RectangleParticle = new RectangleParticle(350,100,400,20,0,true);
			ceil.setStyle(0, colC, 1, colC);
			myBlocks.addParticle(ceil);

			
			var leftWall:RectangleParticle = new RectangleParticle(150,250,20,310,0,true);
			leftWall.setStyle(0, colD, 1, colD);
			myBlocks.addParticle(leftWall);
			
			
			var rightWall:RectangleParticle = new RectangleParticle(550,250,20,310,0,true);
			rightWall.setStyle(0, colE, 1, colE);
			myBlocks.addParticle(rightWall);
			
			
			var midWall:RectangleParticle = new RectangleParticle(230, 250, 160, 20, 0, true);
			midWall.setStyle(0, colE, 1, colD);
			myBlocks.addParticle(midWall);
			
	
			addComposite(myBlocks); //add the composite to the group so collisions can be checked			
			//rightWall.radian += Math.PI/4;
			
		}
		
		
		// add event listeners for every wall in the level! woo!
		public function addEventListeners(event, func) {
			for (var i=0; i<myBlocks.particles.length; i++) {
				//myBlocks.particles[i].addEventListener(event, func);
			}			
		}
		
		
		
		// function to rotate myBlocks - gravity polarizing!
		public function rotate(degrees:Number, centerX:Number, centerY:Number):void {
			myBlocks.rotateByAngle(degrees, new Vector(centerX, centerY));
			
			var radAngle:Number = degrees * Math.PI/180; // convert to radians
			for (var i=0; i<myBlocks.particles.length; i++) {
				myBlocks.particles[i].radian += radAngle;
				myBlocks.particles[i].paint();
			}
		}
	}
}